<style type="text/css">
	.sizetable th,.sizetable td{text-align:center;}
</style>
<div class="page-toolbar" {if $searchdata['showtype'] == 'only_one_sku'}style="display:none"{/if}>
        <div class="page-filter fl">
            <form class="layui-form layui-form-pane" action="{:url()}" method="get" id="hisi-table-search">
            <div class="layui-form-item">	
                <div class="layui-inline">
                    <label class="layui-form-label">SKU</label>
                    <div class="layui-input-inline">
                        <input type="text" name="sku" lay-verify="" value="{$searchdata['sku']}" placeholder="输入SKU" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline show">
                   <label class="layui-form-label">订单号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="client_ordernum" lay-verify="" placeholder="输入订单号" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">所属工厂</label>
                    <div class="layui-input-inline">
                        {:Form::select('factory_id', '', $factoryKV, '', '')}
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">操作类型</label>
                    <div class="layui-input-inline">
                        {:Form::select('action', '4', $actionArr, '', '','style="width:120px;"')}
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">最后更新截止</label>
                    <div class="layui-input-inline time_input">
                        <input type="text" name="over_time_range" readonly="" id="over_time_range" lay-verify="" placeholder="更新截止日期" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
                </div>
            </div>
            </form>
        </div>
    </div>
    <table id="dataTable"></table>
    <table id="detailTable"></table>
    
    {include file="system@block/layui" /}
    <script type="text/html" id="createTimeTpl">
        <div>{{layui.util.toDateString(d.create_time * 1000,'yyyy-MM-dd HH:mm') }}</div>
    </script>
    <script type="text/html" id="updateTimeTpl">
        <div>{{layui.util.toDateString(d.update_time * 1000,'yyyy-MM-dd HH:mm') }}</div>
    </script>
    <script type="text/html" id="stock_count_tpl">
        {{#if(d.available_detail!='' || d.defective_detail!=''){}}
			<table class="sizetable" style="width:100%"><tr><th></th>
				{{# for(var i in d.available_detail_arr){ }}
					<th style="width:40px !important;text-align:center">{{i}}</th>
				{{# } }}
				{{#if(d.available_detail==''){}}
					{{# for(var i in d.defective_detail_arr){ }}
						<th style="width:40px !important;text-align:center">{{i}}</th>
					{{# } }}
				{{#}}}
				</tr>
				{{#if(d.defective_detail==''){}}
				<tr><td>正品</td>
				{{# for(var i in d.available_detail_arr){ }}
					<th>{{d.available_detail_arr[i]}}</th>
				{{# } }}
				</tr>
				{{# } }}
				{{#if(d.defective_detail!=''){}}
					<tr><td>次品</td>
					{{# for(var i in d.defective_detail_arr){ }}
						<th>{{d.defective_detail_arr[i]}}</th>
					{{# } }}
					</tr>
				{{#}}}
				</table>
		{{#}}}
    </script>
    <script type="text/javascript">
        layui.use(['table','opTable', 'tool', 'jquery', 'laydate', 'form'], function() {
        var $ = layui.jquery;
        var laydate = layui.laydate;
        var form = layui.form;
        var table = layui.table;
			{if $searchdata['showtype'] != 'only_one_sku'}
				laydate.render({
					elem: '#over_time_range'
					,change: function(value, date, endDate){
						$('#over_time_range').val(value);
		            }
				});
				table.render({
					elem: '#dataTable'
					,url: '{:url()}' //数据接口
					,page: true //开启分页
					,skin: 'row'
					,even: true
					,limit: 20
					,limits: [20,50,100,150,9999]
					,text: {
						none : '暂无相关数据'
					}
					,toolbar: true
					,defaultToolbar: ['filter', 'exports', 'print']
					,cols: [[ //表头
						{field: 'sku', title: 'SKU',templet:function(d){return '<span class="copy-item" copyText="'+d.sku+'">'+d.sku+'</span>'}}
						,{field: 'pic', title:'图片',templet:function(d){return '<span class="lay-pic-container" src="'+ d.pic +'"><img src="'+ d.pic +'" class="lay-pic" height="65px"></span>'},width:120}
						,{field: 'createTimeTpl', title: '更新时间',templet: '#createTimeTpl', width:150}
						,{field: 'factory_name', title: '工厂'} 
						,{field: 'action', title: '动作',width:80}
						,{field: 'stock_cont_tpl', title: '调整内容',templet: '#stock_count_tpl'}
						,{field: 'client_ordernum', title: '入库订单号'}
						,{field: 'stock_position', title: '货架仓位'}
						,{field: 'remark', title: '出货订单号'}
						,{field: 'actionuser', title: '操作人'}
					]]
				});
			{else /}
				table.render({
					elem: '#dataTable'
					,url: '{:url()}?sku={$searchdata['sku']}' //数据接口
					,page: true //开启分页
					,skin: 'row'
					,even: true
					,limit: 50
					,text: {
						none : '暂无相关数据'
					}
					,toolbar: true
					,defaultToolbar:false
					,cols: [[ //表头
						{field: 'factory_name', title: '工厂', width:140} 
						,{field: 'name', title: '更新时间',templet: '#createTimeTpl', width:150}
						,{field: 'action', title: '动作'}
						,{field: 'stock_cont_tpl', title: '调整内容',templet: '#stock_count_tpl',width:210}
						,{field: 'client_ordernum', title: '入库订单号'}
						,{field: 'stock_position', title: '货架仓位'}
						,{field: 'remark', title: '出货订单号'}
						,{field: 'actionuser', title: '操作人'}
					]]
				});
			{/if}
        });
    </script>